import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path';
import dts from 'vite-plugin-dts'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(), dts({include: './core'})],
    build: {
        lib: {
            entry: './core/index.ts',
            name: 'MpMenu',
        },
        rollupOptions: {
            external: ['vue'],
            output: [
                {
                    format: 'umd',
                    exports: 'named',
                    sourcemap: false,
                    name: 'MpMenu',
                    entryFileNames: 'mp-menu.js',
                    chunkFileNames: '[name].js',
                    assetFileNames: '[name].[ext]',
                    inlineDynamicImports: false,
                    manualChunks: undefined,
                    globals: {vue: 'Vue'}
                }, {
                    format: 'es',
                    exports: 'named',
                    sourcemap: false,
                    name: 'MpMenu',
                    entryFileNames: 'mp-menu.esm.js',
                    chunkFileNames: '[name].js',
                    assetFileNames: '[name].[ext]',
                    inlineDynamicImports: false,
                    manualChunks: undefined,
                    globals: {vue: 'Vue'}
                }
            ]
        }
    },
    resolve: {
        alias: {
            '@': resolve(__dirname, 'src')
        },
    }
})
